<?php

class m_rights_actions_AjaxRefreshSuRightsAction extends f_core_Action
{
	public function execute()
	{
		$rightsService = m_rights_services_RightsService::getInstance();
		$rights = $rightsService->getAllRights();
		$group = $this->getDocumentProvider()->loadDocuments("modules_users/group")->retrieveFirstDocument();
		$rightsService->saveRightsForGroup($group, $rights);
		
		echo "Les droits ont été actualisés";
	}	
	
	public function validate()
	{
        $rightsService = m_rights_services_RightsService::getInstance();
		return $rightsService->isInheritSuGroup($this->getUserContext()->getUser()->getDocumentParent());
	}
	
	public function errorHandler()
	{
		return null;
	}
}